﻿@using CubicFWNet.Data.Models
@using CubicFWNet.Data.ViewModal
@*@model CubicFWNet.Data.Models.FinanceCost*@
@model ProductTechnologyView
@{
    //ViewBag.Title = "价格核算";
    var operationName = ViewBag.OperationName;
    var operationTime = ViewBag.OperationTime;
    var orderId = ViewBag.OrderId;
    var equipment = ViewBag.Equipment as CubicFWNet.Data.Models.Equipment;
    var price = ViewBag.Price;
    var gradeMaintenanceTech = ViewBag.GradeMaintenanceTech as GradeMaintenance;
    var gradeMaintenanceWork = ViewBag.GradeMaintenanceWork as GradeMaintenance;
    var technology = ViewBag.Technology as Technology;
    var financeCost = ViewBag.FinanceCost as FinanceCost;
}
<section class="content-header">
    <h1>
        价格核算
    </h1>
    <ol class="breadcrumb">
        <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i>@Resources.Global.PageTitle</a></li>
        <li><a href="@Url.Action("Index", "Home")">首页</a></li>
        <li class="active"><a href="@Url.Action("CheckOrder", "FinanceCost")">订单查询</a></li>
    </ol>
</section>
<section class="content">
    <div class="box box-solid">
        <!-- /.box-header -->
        <div class="box-body">
            <div class="row">
                <form class="form-horizontal" id="frmedit" action="@Url.Action("AddCheck", "FinanceCost")" method="post">
                    <div class="box-body">
                        @if (Model != null && financeCost != null)
                        {
                            <input type="hidden" id="orderId" name="orderId" value="@orderId" />
                            <input type="hidden" id="OrderProductId" name="OrderProductId" value="@Model.OrderProductId" />
                            <input type="hidden" id="Status" name="Status" value="@financeCost.Status" />
                            <div class="col-md-12" style="border-bottom: 1px solid #ccc; margin-top: 8px;">
                                <div class="form-group col-md-4">
                                    <label class="col-sm-5 control-label">产品</label>
                                    <div class="col-sm-7" style="padding-top: 7px; margin-bottom: 0;">
                                        <a href="javascript:void(0)" class="productinfo" data-id="@Model.ProductId">@Model.ProductName</a>
                                    </div>
                                </div>
                                <div class="form-group col-md-4">
                                    <label class="col-sm-5 control-label">工艺</label>
                                    <div class="col-sm-7" style="padding-top: 7px; margin-bottom: 0;">
                                        <a href="javascript:void(0)" class="technologyinfo" data-id="@Model.TechnologyId">查看工艺</a>
                                    </div>
                                </div>
                                <div class="form-group col-md-4">
                                    <label class="col-sm-5 control-label">数量</label>
                                    <div class="col-sm-7" style="padding-top: 7px; margin-bottom: 0;">
                                        <span class="productinfo" data-id="@Model.ProductId">@Model.Amount</span>
                                    </div>
                                </div>
                                @*<div class="form-group col-md-4" style="display:none">
                                        <label class="col-sm-5 control-label">产品价格</label>
                                        <div class="col-sm-7" style="padding-top: 7px;margin-bottom: 0;">
                                            <span class="productinfo" data-id="@Model.ProductId">@Model.Price</span>
                                        </div>
                                    </div>*@
                                @*<div class="form-group col-md-3">
                                        <label class="col-sm-5 control-label">产品工艺</label>
                                        <div class="col-sm-7" style="padding-top: 7px;margin-bottom: 0;">
                                            <a href="javascript:void(0)" class="technologyinfo" data-id="@item.TechnologyId">@Html.DisplayFor(modelItem => item.ProductName)@Html.Raw("工艺")</a>
                                        </div>
                                    </div>*@
                            </div>
                        }

                        <div class="form-group col-md-12" style="height: 1px;"></div>
                        <div id="json-content">
                            @if (equipment != null && gradeMaintenanceTech != null && gradeMaintenanceWork != null && technology != null && technology.DistributeType == 1)
                            {
                                <div class="form-group col-md-6">
                                    <label class="col-sm-3 control-label">检验人工-元/分钟</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control okeydown" id="TestWork" name="TestWork" value="@gradeMaintenanceTech.Money" data-des="检验人工-元/分钟" readonly="readonly" />
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label class="col-sm-3 control-label">管理费用-元/分钟</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control okeydown" id="ManageWork" name="ManageWork" value="@equipment.ManageWork" data-des="管理费用-元/分钟" readonly="readonly" />
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label class="col-sm-3 control-label">操作人工-元/分钟</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control okeydown" id="OperateWork" name="OperateWork" value="@gradeMaintenanceWork.Money" data-des="操作人工-元/分钟" readonly="readonly" />
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label class="col-sm-3 control-label">设备 工具 折旧-元/分钟</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control okeydown" id="ToolWork" name="ToolWork" value="@equipment.ToolWork" data-des="设备 工具 折旧-元/分钟" readonly="readonly" />
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label class="col-sm-3 control-label">销售费用-元/分钟</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control okeydown" id="SalesWork" name="SalesWork" value="@equipment.SalesWork" data-des="销售费用-元/分钟" readonly="readonly" />
                                    </div>
                                </div>
                                @*<div class="form-group col-md-12" style="height: 1px;"></div>*@

                            }
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">成本价格</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control okeydown" id="PriceConfirm" name="PriceConfirm" value="@price.ToString("f2")" data-des="成本价格" readonly="readonly" />
                                </div>
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                        </div>
                        <div class="form-group col-md-6">
                            <label for="operationName" class="col-sm-3 control-label">操作人</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" id="operationName" name="operationName" value="@operationName" readonly="readonly">
                            </div>
                        </div>
                        <div class="form-group col-md-6">
                            <label for="operationTime" class="col-sm-3 control-label">日期</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" id="operationTime" name="operationTime" value="@operationTime" readonly="readonly">
                            </div>
                        </div>
                    </div>
                    <div class="box-footer" style="width: 80%; margin-left: 20px;">
                        @if (financeCost != null && financeCost.Status == -1)
                        {
                            <a role="button" href="javascript:void(0)" id="submitId" class="btn btn-primary submitbtn" onclick="formsubmit(1)">确认</a>
                        }
                        else
                        {
                            <a role="button" href="javascript:void(0)" id="submitId" class="btn btn-primary submitbtn" onclick="formsubmit(2)">再次核算</a>
                        }

                        <a role="button" href="@Url.Action("CheckOrder", "FinanceCost")" class="btn btn-primary submitbtn">返回</a>
                        <div class="text-red" style="margin-top:20px;font-weight:bold">下一步：销售管理-->确认指导价</div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<div id="loadingPage" style="display: none;">
    <div class="loading-shade"></div>
    <div class="loading-content" onclick="$.loading(false)">数据加载中，请稍后…</div>
</div>

<style>
    .has-error {
        border-color: #dd4b39;
        box-shadow: none;
    }
</style>


@section Scripts{
    <script type="text/javascript">
        $(document).ready(function () {
            $("#frmedit").validate({
                submitHandler: function (form) {
                    var postData = $(form).formSerialize();
                    $.submitForm({
                        url: $(form).attr("action"),
                        param: postData,
                        success: function () {
                            $.modalAlert("操作成功", "success");
                            window.location.href = '@Url.Action("CheckOrder", "FinanceCost")';
                        }
                    });
                }
            });
        });

        function formsubmit(t) {
            if (getParam()) {
                $("#submitId").attr('disabled', "true");
                $("#frmedit").submit();
            }
        }



        $(".okeydown").on("keyup", function () {
            var value = $(this).val();
            if (isNaN(value) || value == "" || value == "Infinity" || value == "NaN") {
                $(this).addClass("has-error");
            } else {
                $(this).removeClass("has-error");
            }
        });


        $(".okeydown").on("keydown", function () {
            var k = event.keyCode;
            if ((k <= 57 && k >= 48) || (k <= 105 && k >= 96) || (k == 8) || (k == 110) || (k == 190)) {
                return true;
            } else {
                return false;
            }
        });

        $(".productinfo").click(function () {
            var id = $(this).data('id');
            var options = {
                id: null,
                title: '产品信息',
                width: "100%",
                height: "100%",
                url: "../Product/Info?PID=" + id,
                shade: 0.3,
                btn: ['返回'],
                btnclass: ['btn btn-danger'],
                callBack: null
            }
            $.modalOpen(options);
        });
        $(".technologyinfo").click(function () {
            var id = $(this).data('id');
            var options = {
                id: null,
                title: '产品信息',
                width: "100%",
                height: "100%",
                url: "../Technology/TechnologyInfo?tId=" + id,
                shade: 0.3,
                btn: ['返回'],
                btnclass: ['btn btn-danger'],
                callBack: null
            }
            $.modalOpen(options);
        });


        function getParam() {
            var flag = true;
            $("#json-content").find('.form-control').each(function (r) {
                var $this = $(this);
                var v = $this.val();
                var des = $this.attr("data-des");
                if (v == "") {
                    flag = false;
                    $.modalAlert(des + "不可为空", "warning");
                    return false;
                }
                if (isNaN(v)) {
                    flag = false;
                    $.modalAlert(des + "格式错误", "warning");
                    return false;
                }
            });
            return flag;
        }
    </script>
}